package com.lagou.edu.listener;

import com.lagou.edu.utils.AnnotationClassPathXmlApplicationContext;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * @author zx
 * @date 2021/6/30 21:13
 * @description
 */
public class WebContextListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("Spring 开始启动加载");
        AnnotationClassPathXmlApplicationContext annotationClassPathXmlApplicationContext = new AnnotationClassPathXmlApplicationContext();
        try {
            annotationClassPathXmlApplicationContext.init("com.lagou.edu");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        System.out.println("Spring 结束加载");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
